package cn.edu.neusoft.yuejian_02.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.squareup.picasso.Picasso;

import java.util.List;

import cn.edu.neusoft.yuejian_02.R;
import cn.edu.neusoft.yuejian_02.activity.ActInfoActivity;
import cn.edu.neusoft.yuejian_02.bean.ActivityBean;
import cn.edu.neusoft.yuejian_02.clas.Constants;
import cn.edu.neusoft.yuejian_02.viewholder.ActivityViewHolder;

/**
 * Created by jj on 2017/10/8.
 */

public class ActivityAdapter extends BaseAdapter{

    public ActivityAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected RecyclerView.ViewHolder onCreateVH(ViewGroup parent, LayoutInflater layoutInflater, int viewType) {
        View itemView = layoutInflater.inflate(R.layout.item_actlist, parent, false);
        ActivityViewHolder viewHolder = new ActivityViewHolder(itemView);
        return viewHolder;
    }

    @Override
    protected void onBindVH(RecyclerView.ViewHolder holder, List data, int position) {
        final ActivityBean entity = (ActivityBean) data.get(position);

        if (null == entity)
            return;
        ActivityViewHolder viewHolder = (ActivityViewHolder) holder;
        viewHolder.act_name.setText(entity.getActivity_name());

        String imageUrl = Constants.ACT_IMG+entity.getPhoto();


        Picasso.with(mContext)
                .load(imageUrl)
                .resize(1000, 500)
                .into(viewHolder.act_pic);


        viewHolder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent intent = new Intent(mContext, ActInfoActivity.class);
                intent.putExtra("ac",entity);
                mContext.startActivity(intent);
            }
        });
    }
}
